clear
import excel "/Users/gwynethmcclendon/Dropbox/Paper AA-GM/Replication materials Overtly Religious Appeals JOP/Study1.xlsx", sheet("Survey_March 23, 2021_18.19") firstrow

destring, replace

**Treatments**

*Generate numeric message treatments and dummies for each
encode message, gen(message_treat)
gen message_multi=0
recode message_multi (0=1) if message_treat==1

gen message_overt=0
recode message_overt (0=1) if message_treat==2

gen message_sec=0
recode message_sec (0=1) if message_treat==3

gen message_rel=0
replace message_rel=1 if message_treat==1 | message_treat==2

**Code outcome variables**

*Generate Support for candidate 
gen candsupport=support
replace candsupport= AT if candsupport==.
replace candsupport= AZ if candsupport==.

*Generate candidate qualified
gen candqualified= qualified
replace candqualified= AU if candqualified==.
replace candqualified= BA if candqualified==.

*Generate candidate represents
gen candrepresent=represent
replace candrepresent=AV if candrepresent==.
replace candrepresent=BB if candrepresent==.

*Generate candidate religious
gen candreligious=religious
replace candreligious= AW if candreligious==.
replace candreligious=BC if candreligious==.

*Generate candidate eloquent
gen candeloquent= eloquent
replace candeloquent= AX if candeloquent==.
replace candeloquent= BD if candeloquent==.


*Generate candidate thoughtful
gen candthoughtful=thoughtful
replace candthoughtful=AY if candthoughtful==.
replace candthoughtful=BE if candthoughtful==.

**measure of compliance with dangers treatment***
sum danger_takeup if dangers==1


**Code democratic covariates**

*Rename Religious
rename Religious responrelig

*Generate Christian Nationalism scale (Note that cnat_5 is not included because it was an attention check and cnat_3 is reverse coded)
gen cnat= cnat_1+ cnat_2+6- cnat_3+ cnat_4+ cnat_6+ cnat_7
sum cnat
sum cnat, d
gen high_cnat=0
replace high_cnat=1 if cnat>19 & cnat~=.
replace high_cnat=. if cnat==.
tab responrelig high_cnat


*Generate party numeric (note that this includes leaners)
encode Party, gen(party_num)
gen democrat=0
replace democrat=1 if party_num==1
gen republican=0 
replace republican=1 if party_num==2

tab responrelig republican, row

*For pure partisans use these variable
gen democratpid=1 if pid1==1
recode democratpid (.=0)

gen republicanpid=1 if pid1==2
recode republicanpid (.=0)

gen independentpid=1 if pid1==3
recode independentpid (.=0)


recode pid1 (1=1) (2=3) (3=2), gen(pid_reordered)
label define pidlabel 1 "Democrat" 2 "Independent" 3 "Republican" 
label values pid_reordered pidlabel

*Age
gen age=2021-year_born

*Race
split race, p(",")
destring race1 race2 race3 race4, replace

gen asian=1 if race1==1 
recode asian (.=0)
gen black=1 if race1==2 
recode black (.=0)
gen nativeamerican=1 if race1==3 
recode nativeamerican (.=0)
gen white=1 if race1==4 
recode white (.=0)
gen other=1 if race1==5 
recode other (.=0)
gen mixedrace=1 if race2!=.
recode mixedrace (.=0)

recode latino (2=0)

*Gender
recode gender (1=0) (2=1) (3 4=.), gen(female)

*Education
gen college=0 if educ==1 | educ==2 | educ==3 | educ==4
replace college=1 if educ==5 | educ==6 |educ==7

*Political participation
gen evervoted=0
replace evervoted=1 if voted_ever==1

recode voted_2020 (2=0)

recode voted_2020 (.=0) if evervoted==0

recode workpols (2=0)

*Religiosity
recode oftenservices (1=5) (2=4) (3=3) (5=1) (4=2), gen(oftenservices_reordered)
label define oftenserviceslabel 1 "Never" 2 "A Few Times a Year" 3 "Once or Twice a Month" 4 "Almost Every Week" 5 "Every week"
label values oftenservices_reordered oftenserviceslabel

gen veryreligious=0
replace veryreligious=1 if oftenservices_reordered==4 | oftenservices_reordered==5

gen mostreligious=0
replace mostreligious=1 if oftenservices_reordered==5

gen childrelig=.
replace childrelig=1 if often12==1 | often12==2 | often12==3
replace childrelig=0 if often12==4 | often12==5 

gen believeingod=.
replace believeingod=1 if deitybelief==1 | deitybelief==2 | deitybelief==3
replace believeingod=0 if deitybelief==4 | deitybelief==5 | deitybelief==6 | deitybelief==7

recode deitybelief (1 2 3 4 =1) (5 6 7=0), gen(spiritual)

recode deitybelief (1=1) (2 3 4 5 6 7 =0), gen(beliefgodnodoubts)

gen mostfervent=0
replace mostfervent=1 if beliefgodnodoubts==1 & oftenservices==1

gen somehoursreligious=.
replace somehoursreligious=1 if timereligious>1 & timereligious~=.
replace somehoursreligious=0 if timereligious==1 

gen timereligious_rev=.
replace timereligious_rev=timereligious if timereligious>1 & timereligious~=.
replace timereligious_rev=0 if timereligious==1 

tab spiritual responrelig /*78% of people who don't attend regularly are nevertheless spiritual*/

gen supersecular=0
replace supersecular=1 if responrelig==0 & somehoursreligious==0 & beliefgodnodoubts==0

gen superreligious=0
replace superreligious=1 if responrelig==1 & somehoursreligious==1 & beliefgodnodoubts==1

*Region
recode region (2 3 4=0), gen(northeast)
recode region (2=1) (1 3 4=0), gen(midwest)
recode region (3=1) (1 2 4=0), gen(south)
recode region (4=1) (1 2 3=0), gen(west)

*Denomination
tab religion, gen(denom)
rename denom1 catholic
rename denom2 mainline
rename denom3 evangelical
rename denom4 otherchristian
rename denom5 agnostic
rename denom6 atheist
rename denom7 none

gen notrelig=agnostic+atheist+none

*Attention check question
gen inattentive=1
replace inattentive=0 if cnat_5==5 
replace inattentive=. if cnat_5==.


****Compliance with Dangers Prompt***
gen compliance_coder1=danger_takeup

gen compliance_coder2=0
replace compliance_coder2=1 if compliance_julieta==1

gen compliance_coder3=0
replace compliance_coder3=1 if compliance_lexi_redone==1

gen compliance_dangers=0
replace compliance_dangers=1 if compliance_coder1==1 & compliance_coder2==1 & compliance_coder3==1

***************
***Figure 3****
***************

*Figure 3: Perceptions of Candidate Religiosity in Evaluation Task, Among Respondents with No Dangers Prime
recode message_treat (1=2) (2=1) (3=3), gen(message_reordered)
collapse (mean) meancandreligious=candreligious (semean) secandreligious=candreligious if dangers==0, by(message_reordered responrelig)
gen hireligious=meancandreligious+1.96*secandreligious
gen lowreligious=meancandreligious-1.96*secandreligious
label define responreliglabel 0 "Not Religious Respondents" 1 "Religious Respondents"
label values responrelig responreliglabel

twoway (bar meancandreligious message_reordered if message_reordered==2, fcolor(white) lcolor(black))(bar meancandreligious message_reordered if message_reordered==1, fcolor(gray) lcolor(black)) (bar meancandreligious message_reordered if message_reordered==3, fcolor(darkgray) lcolor(black))  (rcap hireligious lowreligious message_reordered, lcolor(black)), xscale(off) xlabel(1   "Overtly Religious" 2   "Multi-Vocal"  3 "Secular", labels labsize(small)) by(, legend(off)) by(, graphregion(fcolor(white)) plotregion(fcolor(white))) by(responrelig, note("")) subtitle( , fcolor(white) lcolor(white))  ytitle("Candidate Religiosity (5=Very Religious)") ysc(r(0 5)) ytick(0 (1) 5, labels) xtitle("") 
